{$A+,B-,D-,E-,F-,G+,I-,L-,N-,O-,R-,S-,V-,X-}

program redbar;

var     c        : byte;
        c2,c3,c4 : word;
        sintab   : array [0..127] of word;
        headptr:word absolute $40:$1A;
        tailptr:word absolute $40:$1C;
begin
  for c:=0 to 127 do
    sintab[c]:=trunc((sin((2*pi/128)*c)+1)*135);
  c3:=100;
  repeat
    inline($FA);
    repeat until (port[$3DA] and 8)>0;
    repeat until (port[$3DA] and 8)=0;
    for c4:=0 to sintab[c3 and 127] do begin
      repeat until (port[$3DA] and 1)=0;
      repeat until (port[$3DA] and 1)>0;
    end;
    for c:=0 to 63 do begin
      repeat until (port[$3DA] and 1)>0;
      port[$3C8]:=0;
      port[$3C9]:=C;
      port[$3C9]:=0;
      port[$3C9]:=0;
      repeat until (port[$3DA] and 1)=0;
    end;
    for c:=63 downto 0 do begin
      repeat until (port[$3DA] and 1)>0;
      port[$3C8]:=0;
      port[$3C9]:=C;
      port[$3C9]:=0;
      port[$3C9]:=0;
      repeat until (port[$3DA] and 1)=0;
    end;
    port[$3C8]:=0;
    port[$3C9]:=0;port[$3C9]:=0;port[$3C9]:=0;
    inc(c3);
    inline($FB);
  until headptr<>tailptr;
  headptr:=tailptr;
end.